<?php
namespace app\admin\validate;
use think\Validate;

/**
 * 学习信息验证器
 * Created by PhpStorm.
 * User: tyll
 * Date: 2019/10/22
 * Time: 17:03
 */
class ClassLearn extends Validate{

    protected $rule = [
        'active_name'   => 'require',
        'active_title'  => 'require',
        'active_object' => 'require',
        'active_time'   => 'require',
        'active_unit'   => 'require',
        'is_repeat_ti'  => 'require',
        'start_time'    => 'require|date',
        'end_time'      => 'require|date|gt:start_time',
        'score_type'    => 'require',
        'ti_num'        => 'require|integer|gt:0',
        'per_ci_num'    => 'require|integer|gt:0',
        'per_ti_score'  => 'require|integer|gt:0',
        'zeng_score'    => 'require|integer|egt:0',
        'dati_time'     => 'require|integer|gt:0',
        'ckid'          => 'require',
        'active_rule'   => 'require'
    ];

    protected $message = [
        'active_name.require'   => '学习名称必须填写',
        'active_title.require'  => '学习标题必须填写',
        'active_object.require' => '学习对象必须填写',
        'active_time.require'   => '学习时间必须填写',
        'active_unit.require'   => '主办单位必须填写',
        'is_repeat_ti'          => '是否重复出题必须填写',
        'start_time.require'    => '开始时间必须填写',
        'start_time.date'       => '开始时间填写错误',
        'end_time.require'      => '结束时间必须填写',
        'end_time.date'         => '结束时间填写错误',
        'end_time.gt'           => '结束时间必须大于开始时间',
        'score_type.require'    => '打分类型必须填写',
        'ti_num.require'        => '题目数量必须填写',
        'ti_num.integer'        => '题目数量填写错误',
        'ti_num.gt'             => '题目数量填写错误',
        'per_ci_num.require'    => '每天答题次数必须填写',
        'per_ci_num.integer'    => '每天答题次数填写错误',
        'per_ci_num.gt'         => '每天答题次数填写错误',
        'per_ti_score.require'  => '每题分数必须填写',
        'per_ti_score.integer'  => '每题分数填写错误',
        'per_ti_score.gt'       => '每题分数填写错误',
        'zeng_score.require'    => '赠送分数必须填写',
        'zeng_score.integer'    => '赠送分数填写错误',
        'zeng_score.egt'        => '赠送分数填写错误',
        'dati_time.require'     => '答题时长必须填写',
        'dati_time.integer'     => '答题时长填写错误',
        'dati_time.gt'          => '答题时长填写错误',
        'ckid.require'          => '题库id必须填写',
        'active_rule.require'   => '学习规则必须填写'
    ];

    protected $scene = [
        'add'  => ['active_name','active_title','active_object','active_time','active_unit','is_repeat_ti','start_time','end_time','score_type','ti_num','per_ci_num','per_ti_score','zeng_score','dati_time','ckid','active_rule'],
        'edit' => ['active_name','active_title','active_object','active_time','active_unit','is_repeat_ti','start_time','end_time','score_type','ti_num','per_ci_num','per_ti_score','zeng_score','dati_time','ckid','active_rule']
    ];
}